import requests
import json
import backend.app.app.api.utils.encryption as enc


headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36",
    "Content-Type": "application/json;charset=UTF-8",

}

post_body = {
    "username": "test-1",
    "password": enc.rsa_encrypt("123456"),
}
session = requests.session()
# response = session.post("http://47.96.235.182:8885/api_v1/user/login", data=json.dumps(post_body), headers=headers)
response = session.post("http://127.0.0.1:8889/api_v1/user/login", data=json.dumps(post_body), headers=headers)
if response.status_code == 200:
    response = json.loads(response.text)
    # print(response)
    # print(response)
    print(response['access_token'])
# print(json.dumps(response))

# import jwt
#
# print(jwt.decode(jwt="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyLTEiLCJzdGF0dXMiOiJhZG1pbiIsImlhdCI6MTY0NzI0NTY1NCwiZXhwIjoxNjQ3MjUxNjU0LCJhdmFpbGFibGUiOnRydWV9._wcFEjEGDEeugaW5EgDUw9wNB21QfSjaFVZJ2pyYfAI", key="09d25e094faa6ca2556c8fjdklf920jfdks2j0f563b93f7099f6f0f4caa6cf63b88e8d3e7", algorithms="HS256"))